package chapter26;

import java.util.Arrays;
import java.util.List;
import java.util.TreeSet;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2019/2/28 15:13
 */
public class StreamTest2 {
    public static void main(String[] args) {
        List<String> list = Arrays.asList(new String[]{"abc", "def", "hello", "ABC", "abstract"});
        List<String> reList = list.stream()
                .distinct()
                .filter(s -> s.trim().length() <= 3)
                .peek(System.out::println)
                .map(String::toLowerCase)
                .distinct()
                .collect(Collectors.toList());
        System.out.println(reList);

        Stream.generate(Math::random).limit(10).forEach(System.out::println);

        Stream.iterate(1, t -> t + 2).limit(100).forEach(System.out::println);

        TreeSet<String> lhSet = list.stream().collect(Collectors.toCollection(TreeSet::new));
        System.out.println(lhSet);

    }
}
